import "./App.css";
import { BrowserRouter } from "react-router-dom";
// BrowserRouter HashRouter
import Router from "@/routers/index";
import { Provider } from "react-redux";
import store from "@/redux/index";
import useTheme from "@/hooks/useTheme";

import { ConfigProvider, theme } from "antd";
import "@/styles/theme/theme-dark.less";
import "@/styles/theme/theme-default.less";

import { useSelector } from "react-redux";

function App(props: any) {
  const theme = useSelector((state: any) => state.theme.value);
  const { themeConfig } = props;
  // 全局使用主题
  useTheme(themeConfig);
  // 国际化
  return (
    <BrowserRouter>
      <ConfigProvider
        theme={{
          // 1. 单独使用暗色算法
          algorithm:
            theme == "default" ? theme.defaultAlgorithm : theme.darkAlgorithm,
        }}
      >
        <Provider store={store}>
          <Router />
        </Provider>
      </ConfigProvider>
    </BrowserRouter>
  );
}

export default App;
